public class Test12 {
    public static void main(String[] args) {
        Test12 test = new Test12();
        int result = test.a(5);
        System.out.println("Index of  5 is: " + result);
    }
    public int a(int searchNum) {
        int[] arr = {1, 3, 4, 6, 9, 18, 22};
        int left = 0;
        int right = arr.length - 1;
        while (left<=right){
            int center = left + (right - left) / 2;
            if (arr[center] < searchNum) {
                left = center + 1;
            } else if (arr[center] > searchNum) {
                right = center - 1;
            } else {
                return center;
            }
        }
        return -1;
    }

}
